// pages/addrListPage/address-list.js
Page({
  data: {
    userAddr: {}
  },

  onLoad(options) {
    var that = this;
    var db = wx.cloud.database()
    // 获取用户地址列表
    db.collection('address').get({
      success(res) {
        that.setData({
          userAddr:res.data
        });
        console.log('获取地址',that.data.userAddr)
      },
      fail(err) {
        console.log(err)
      },       
    })
    
  },
  delete(res){
    var db = wx.cloud.database()
    console.log(res.currentTarget.dataset.tel)
    db.collection('address').where({
      telNumber:res.currentTarget.dataset.tel
    }).remove({
      success(res){
        console.log('删除成功！')
      },
      fail(err){
        console.log('删除失败！')
      }
    })
    wx.navigateTo({
      url: '../address-Manage/address-list',
    })
  }
})